package com.owc.common.enums;

import lombok.Getter;

import java.util.Arrays;
import java.util.Optional;

@Getter
public enum StatusEnum {
    FAIL(-20,"失败"),
    REFUSE(-1,"拒绝"),
    PASSED(5,"通过"),
    SUCCESS(10,"成功"),
    PENDING(20,"审核中"),
    CONFIRM(30,"确认中"),
    CANCELING(40,"取消中"),
    CANCEL(50,"取消成功"),
    CANCELFAIL(60,"取消失败")
    ;

    StatusEnum(Integer type, String desc) {
        this.type = type;
        this.desc = desc;
    }

    private Integer type;

    private String desc;

    public static Optional<StatusEnum> match(Integer type){
        return Arrays.stream(StatusEnum.values())
                .filter(t -> t.getType().equals(type))
                .findFirst();
    }
}
